package com.njym.java.security.admin.rest;

import com.github.pagehelper.PageHelper;
import com.njym.java.security.admin.biz.FamilyCounselorBiz;
import com.njym.java.security.admin.entity.FamilyCounselor;
import com.njym.java.security.admin.entity.FamilyCounselorVo;
import com.njym.java.security.common.msg.ObjectRestResponse;
import com.njym.java.security.common.rest.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("familyCounselor")
public class FamilyCounselorController extends BaseController<FamilyCounselorBiz,FamilyCounselor> {

    @Autowired
    private FamilyCounselorBiz familyCounselorBiz;

    @RequestMapping(value = "/getList",method = RequestMethod.GET)
    @ResponseBody
    public ObjectRestResponse<FamilyCounselorVo> getList(@RequestParam(defaultValue = "1") int page,
                                                         @RequestParam(defaultValue = "20") int limit,
                                                         String conCode, Integer star,
                                                         String jonLev, Integer status, String attr2){

        PageHelper.startPage(page,limit);
        List<FamilyCounselorVo> rows = familyCounselorBiz.getList(conCode, star, jonLev, status, attr2);
        Integer total = familyCounselorBiz.selectCounts(conCode, star, jonLev, status, attr2);
        Map<String, Object> data = new HashMap<>(2);
        data.put("rows", rows);
        data.put("total", total);
        return new ObjectRestResponse<FamilyCounselorVo>().rel(true).data(data);
    }

}